package cn.edu.cdu.health.common;

//设计一个统一的给前端的返回类型

import lombok.Data;

import java.io.Serializable;

@Data
public class  R implements Serializable {
    private Integer code;
    private String  msg;
    private Object data;

    //请求成功的方法
    public static R ok(){
        R r= new R();
        r.code =200;
        r.msg="ok";
        return r;
    }
    //请求成功，并返回数据给前端
    public static R ok(Object data){
        R r=ok();
        r.data =data;
        return r;
    }

    public static R failed(){
        R r= new R();
        r.code =500;
        r.msg="failed";
        return r;
    }
    public static R failed(String msg){
        R r= new R();
        r.code =500;
        r.msg=msg;
        return r;
    }

}
